
import java.util.concurrent.*;

public class SessionsManager {

	private final static ConcurrentMap<String,Source> _socketsList = new ConcurrentHashMap<String, Source>();
	
	private final static ConcurrentHashMap<Source, String> _peerList = new ConcurrentHashMap<Source, String>();
	
	// set functions //
	public  final static void setSocket(String peerName, Source source){
		_socketsList.put(peerName, source);
		_peerList.put(source, peerName);
	}
	
	// get functions //
	/**
	 * Get communication information by peer name.
	 */
	public final static Source getSocket(String peerName) { return _socketsList.get(peerName); }
		
	/**
	 * Get peer name by communication details (Source object)
	 * @param source
	 * @return
	 */
	public final static String getNameBySource(Source source) { return _peerList.get(source); }
	
	/**
	 * Clean communication information for input peer 
	 * @param peerName
	 */
	public final static void removePeer(String peerName){ _socketsList.remove(peerName); }
	
	
}
